﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ITAP.Core.Modelling;


namespace ITAP.ContourBuilder.GUI
{
    public delegate void PropertiesChangedDelegate();

    public partial class FormHoleProperties : Form
    {
        public ModelPoint HolePosition
        {
            get
            {
                return new ModelPoint((double)numericUpDownX.Value, (double)numericUpDownY.Value);
            }
            set
            {
                numericUpDownX.Value = (decimal)value.X;
                numericUpDownY.Value = (decimal)value.Y;
            }
        }

        public event PropertiesChangedDelegate PropertiesChanged;

        public double Radius
        {
            get
            {
                return (double)numericUpDownRadius.Value;
            }
            set
            {
                numericUpDownRadius.Value = (decimal)value;
            }
        }

        public FormHoleProperties()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void numericUpDownRadius_ValueChanged(object sender, EventArgs e)
        {
            if(this.PropertiesChanged != null)
                this.PropertiesChanged.Invoke();
        }

        private void numericUpDownX_ValueChanged(object sender, EventArgs e)
        {
            if (this.PropertiesChanged != null)
                this.PropertiesChanged.Invoke();
        }

        private void numericUpDownY_ValueChanged(object sender, EventArgs e)
        {
            if (this.PropertiesChanged != null)
                this.PropertiesChanged.Invoke();
        }
    }
}
